package com.bawei.module_my.myorder;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.bawei.library_base.RouterPath;
import com.bawei.library_base.mvp.v.BaseActivity;
import com.bawei.library_base.room.paygood.PayGood;
import com.bawei.library_base.room.paygood.PayGoodDatabase;
import com.bawei.module_my.R;

import java.util.ArrayList;
import java.util.List;

@Route(path = RouterPath.Pay.PAY)
public class MyOrderActivity extends BaseActivity {


    private RecyclerView myOrderRv;

    @Override
    public int beanLayout() {
        return R.layout.activity_my_order;
    }

    @Override
    public void initView() {

        myOrderRv = (RecyclerView) findViewById(R.id.my_order_rv);
        myOrderRv.setLayoutManager(new StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.VERTICAL));
    }

    @Override
    public void initData() {

        //适配
        adapter();
    }

    private void adapter() {
        List<PayGood> allGood = PayGoodDatabase.getInstance(getApplicationContext()).getPayGoodDao().getAllGood();


        ArrayList<PayGood> payGoods = new ArrayList<>();

        for (PayGood payGood : allGood) {
            if (payGood.isPcheck()){
                payGoods.add(payGood);
            }
        }
        MyOrderAdapter myOrderAdapter = new MyOrderAdapter(payGoods);
        myOrderRv.setAdapter(myOrderAdapter);
    }
}